﻿@using System.Web.Http
@using sharp_net.Mvc.HelpPage
@model HelpPageApiModel

@{ 
    var description = Model.ApiDescription;
    bool hasParameters = description.ParameterDescriptions.Count > 0;
    bool hasRequestSamples = Model.SampleRequests.Count > 0;
    bool hasResponseSamples = Model.SampleResponses.Count > 0;
}
<h1>@description.HttpMethod.Method @description.RelativePath</h1>
<div>
    @if (description.Documentation != null) {
        <p>@description.Documentation</p>
    } else {
        <p>No documentation available.</p>
    }

    @if (hasParameters || hasRequestSamples) {
        <h2>Request Information</h2>
        if (hasParameters) {
        <h3>Parameters</h3>
        @Html.DisplayFor(apiModel => apiModel.ApiDescription.ParameterDescriptions, "Parameters")
        }
        if (hasRequestSamples) {
        <h3>Request body formats</h3>
        @Html.DisplayFor(apiModel => apiModel.SampleRequests, "Samples", new { sampleClass = "request" })
        }
    }

    @if (hasResponseSamples) {      
        <h2>Response Information</h2> 
        <h3>Response body formats</h3>
        @Html.DisplayFor(apiModel => apiModel.SampleResponses, "Samples", new { sampleClass = "response" })
    }
</div>
<br />
@if (HttpContext.Current.IsDebuggingEnabled && Model.ErrorMessages.Count > 0) {
    foreach (string errorMessage in Model.ErrorMessages) {
    <div class="ui-state-highlight ui-corner-all warning-message-container">
        <p>
            <span class="ui-icon ui-icon-info warning-message-icon"></span>
            @errorMessage
        </p>
    </div>
    }
}